package com.wjk.kylin.mall.order.mq;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *
 */
@Slf4j
@Component
public class MyConsumer{

    @Autowired
    private OrderHandler orderHandler;

    public Boolean consumer(MessageDTO msg) {
        log.info("MyHandlerImpl-msg:{}", JSON.toJSONString(msg));
        Boolean flag = false;
        try {
            switch (msg.getMsgType()) {
                case 1:
                    flag = orderHandler.handler(msg);
                    break;
                case 2:
                    log.info("2");
                    break;
                case 3:
                    log.info("3");
                    break;
                case 4:
                    log.info("4");
                    break;
                default:
                    log.info("default");
            }
        } catch (Exception e) {
            log.error(e.getMessage());
        }
        return flag;
    }
}
